<script setup lang="ts">
import {formatDuration, timeFormat} from '@/utils/gps/format'
import { ref, toRefs } from "vue";
import { recordSelect } from "@/utils/tool";
import {nanoid} from "nanoid";

const props = defineProps<{recordData: {stops: any[], trips: any[]}}>()
const playingRecord = ref("")

const { stops } = toRefs(props.recordData)

function parentClick(event){
  if(event.target.nodeName !== "LI") return
  recordSelect(event, playingRecord)
}
</script>

<template>
  <ul style="padding-right: 10px" @click="parentClick">
    <li v-for="(item, index) in stops" :key="index" class="item" :data-key="nanoid()">
      <div class="top_info">
        <span class="number">{{ index + 1 }}</span>
        <span>{{ item.startTime }}</span>
        <span>{{ timeFormat(item.duration) }}</span>
      </div>
      <p class="position">{{item.address}}</p>
    </li>
  </ul>
</template>

<style scoped>
.item {
  border: 1px solid #bdbdbd;
  border-radius: 5px;
  padding: 10px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
}
li{
  cursor: pointer;
}
li:hover{
  background-color: rgb(245, 247, 250);
}
li> *{
  pointer-events: none;
}
.on{
  background-color: rgb(204, 205, 206)!important;
}
.number{
  background-color: #00AAFF;
  color: white;
  border-radius: 50%;
  display: inline-block;
  width: 18px;
  height: 18px;
  text-align: center;
  line-height: 18px;
}
.top_info{
  display: flex;
  align-items: center;
}
.top_info>span:nth-child(2){
  text-align: left;
  flex: 1;
  margin: 0 15px;
}
.position{
  margin-top: 8px;
}
</style>
